-
Notifications
You must be signed in to change notification settings - Fork 550
fix(langchain): Make span_map
an instance variable
#4476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(langchain): Make span_map
an instance variable
#4476
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #4476 +/- ##
==========================================
- Coverage 80.70% 80.69% -0.02%
==========================================
Files 156 156
Lines 16475 16474 -1
Branches 2799 2799
==========================================
- Hits 13296 13293 -3
- Misses 2296 2298 +2
Partials 883 883
|
329ed33
to
906f75f
Compare
906f75f
to
876e6fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Was this an actual problem or is this more of a nice-to-have small refactor? As I understand from the other PR, we're actively avoiding having more than one SentryLangchainCallback
around at a time.
I think the change itself is fine but we don't need tests for an implementation detail like this. We also don't test that max_span_map_size
, include_prompts
, etc. are not shared between instances. (And we also shouldn't test that, because it's not behavior worth testing, and the tests would just add clutter without any signal.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment, looks good but let's remove the tests (or at least test_span_map_not_class_attribute
)
@sentrivana Yes, so the problem occurred when attempting to reproduce #4443. I was confused why, despite having two callbacks, the data in Sentry was not duplicated. I assumed that perhaps the
The reason, of course, is that the first callback which ends deletes the span from the Of course, you are right that we try to only have one callback per LLM request in #4485. But, what happens if we have concurrent requests to LLMs, or some other more complex setup, where having two callbacks would be expected? I am unsure how realistic such setups are, but if they do occur, I am pretty confident that we don't want the span map to be shared between the instances. |
Not against the change itself, seems reasonable in any case. I was more pondering if this is behavior that needs testing (rather than a small internal refactor), but if you believe it is, I'd say |
sounds reasonable, the first test is definitely more important anyhow |
876e6fb
to
becd3ea
Compare
becd3ea
to
d71743f
Compare
span_map
should be an instance variable; otherwise, separate instances of theSentryLangchainCallback
share the samespan_map
object, which is clearly not intended here.Also, remove the
max_span_map_size
class variable, it is always set on the instance, and so not needed.Ref #4443